package com.yuhang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuhang.entity.HyCar;
import com.yuhang.entity.HyPet;
import com.yuhang.mapper.HyCarMapper;
import com.yuhang.service.HyCarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuhang
 * @since 2021-04-24
 */
@Service
public class HyCarServiceImpl extends ServiceImpl<HyCarMapper, HyCar> implements HyCarService {

    @Autowired
    private HyCarMapper hyCarMapper;

    @Override
    public IPage<HyCar> selectByPage(int pageNum, int pageSize,String likename) {
        Page<HyCar> page = new Page(pageNum,pageSize);
        QueryWrapper<HyCar> wrapper = new QueryWrapper<>();
        if(likename!=null&&!likename.equals("")){
            wrapper.like("user_name",likename);
        }
        IPage<HyCar> hyCarIPage = hyCarMapper.selectPage(page,wrapper);
        return hyCarIPage;
    }

    @Override
    public IPage<HyCar> selectByPage(int pageNum, int pageSize,int userid) {
        Page<HyCar> page = new Page(pageNum,pageSize);
        QueryWrapper<HyCar> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userid);
        IPage<HyCar> hyCarIPage = hyCarMapper.selectPage(page,wrapper);
        return hyCarIPage;
    }
}
